<!-- 模型库上传弹框 -->
<template>
  <el-dialog
    :title="title"
    :visible.sync="dialogFormVisible"
    custom-class="common-dialog"
    :close-on-click-modal="false"
  >
    <el-form :model="form" :rules="rules" label-position="top">
      <el-form-item label="版本ID" prop="version">
        <el-input v-model="form.version" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="描述" prop="description">
        <el-input
          type="textarea"
          v-model="form.description"
          autocomplete="off"
        ></el-input>
      </el-form-item>
      <el-form-item label="上传人" prop="upload_user">
        <el-input v-model="form.upload_user" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="源码" prop="code_zip">
        <el-upload
          ref="uploadFile2"
          action="string"
          :limit="1"
          accept=".zip,.tar"
          :on-change="handleChangeCodeZip"
          :auto-upload="false"
          :file-list="fileList1"
          :show-file-list="false"
        >
          <el-input
            v-model="form.code_zip"
            placeholder="点击此处上传源码"
            autocomplete="off"
          ></el-input>
        </el-upload>
      </el-form-item>
      <el-form-item label="动态链接库" prop="dynamic_link_library">
        <el-upload
          ref="uploadFile2"
          action="string"
          :limit="1"
          accept=".zip,.tar"
          :on-change="handleChangeDynamic"
          :auto-upload="false"
          :file-list="fileList2"
          :show-file-list="false"
        >
          <el-input
            v-model="form.dynamic_link_library"
            placeholder="点击此处上传动态链接库"
            autocomplete="off"
          ></el-input>
        </el-upload>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button class="cancel-btn" @click="cancel">取 消</el-button>
      <el-button class="submit-btn" @click="cancel">确 定</el-button>
    </div>
  </el-dialog>
</template>
  
  <script>
export default {
  data() {
    return {
      title: "",
      dialogFormVisible: false,
      form: {},
      fileList1: [], // 上传源码的文件列表
      fileList2: [], // 上传动态链接库的文件列表
      rules: {
        name: [{ required: true, message: "请输入名称", trigger: "blur" }],
      },
    };
  },
  methods: {
    init(row) {
      this.dialogFormVisible = true;
      this.reset();
      if (!row) {
        this.title = "模型库上传";
      } else {
        this.title = "修改模型库";
        this.form.version = row.version;
        this.form.uploload_user = row.uploload_user;
        this.form.code_zip = row.code_zip;
        this.form.dynamic_link_library = row.library_zip;
      }
    },
    // 当上传的源码文件发生变化时
    handleChangeCodeZip(file, fileList) {},
    // 当上传的动态链接库文件发生变化时
    handleChangeDynamic(file, fileList) {},
    reset() {
      this.form = {
        version: null,
        description: null,
        upload_user: null,
        code_zip: null,
        dynamic_link_library: null,
      };
    },
    cancel() {
      this.dialogFormVisible = false;
    },
  },
};
</script>
  
